package com.vn.rainbow.exoalarm.activity;

import java.util.Calendar;

import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;

import com.github.clans.fab.FloatingActionButton;
import com.vn.rainbow.exoalarm.R;
import com.vn.rainbow.exoalarm.ui.TimeSetlectedView;
import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;

public class SetAlarmActivity extends BaseActivity implements OnClickListener,
		TimePickerDialog.OnTimeSetListener {
	private Context mContext;
	private FloatingActionButton fabSave;
	private TimeSetlectedView mTimeSelected;
	private boolean is24HourFormat;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fragment_set_alarm);

		mContext = getApplicationContext();

		setTitle("Set Alarm");

		

		mTimeSelected = (TimeSetlectedView) findViewById(R.id.time_selected);
		mTimeSelected.setOnClickListener(this);

	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
		// TODO Auto-generated method stub
		String am = "AM";
		if (!is24HourFormat && hourOfDay > 12) {
			am = "PM";
			hourOfDay -= 12;
		}

		if (!is24HourFormat && hourOfDay == 0)
			hourOfDay = 12;

		String hourString = Integer.toString(hourOfDay);
		if (hourString.length() == 1)
			hourString = "0" + hourString;

		String minuteString = Integer.toString(minute);
		if (minuteString.length() == 1)
			minuteString = "0" + minuteString;

		mTimeSelected.setChangeTime(hourString + ":" + minuteString, am,
				is24HourFormat);

	}
}
